import { createSlice } from '@reduxjs/toolkit'
import type { PayloadAction } from '@reduxjs/toolkit'
import type { RootState } from './index'
import { SaveChangeData } from '@/types/changeCourse/index'

interface CourseState {
  successInfo: Partial<SaveChangeData> | undefined
}
const initialState: CourseState = {
  /**调课成功*/
  successInfo: {},
}

export const courseSlice = createSlice({
  name: 'course',
  initialState,
  reducers: {
    setChangeSuccess: (state, action: PayloadAction<SaveChangeData>) => {
      state.successInfo = action.payload
    },
  },
})

export const { setChangeSuccess } = courseSlice.actions
export const successInfo = (state: RootState) => state.changeCourse.successInfo
export default courseSlice.reducer
